package com.smart.lx.singleton.lazy;

/**
 * 功能描述: <br>
 * 〈延迟加载〉
 * <p>
 * 先保证能进方法
 *
 * @since: 1.0.0
 * @Author:abc
 * @Date: 2019/3/10
 */
public class LazyDoubleCheckSing {
    private volatile static LazyDoubleCheckSing lazy = null;

    private LazyDoubleCheckSing(){}
    public static LazyDoubleCheckSing getInstance(){
        if(lazy == null){
            synchronized (LazyDoubleCheckSing.class){
                if(lazy == null){
                    lazy = new LazyDoubleCheckSing();
                    //1.分配内存给这个对象
                    //2.初始化对象
                    //3.设置lazy指向刚分配的内存地址
                    //2 和3 顺序可能每次不一样
                    //4.初次访问对象
                }
            }
        }
        return lazy;
    }

}
